//
//  StoppingTabBarVC.m
//  TT
//
//  Created by Lenny on 16/4/14.
//  Copyright © 2016年 Lenny. All rights reserved.
//

#import "StoppingTabBarVC.h"
#import "MovingTabBarVC.h"
#import "ViewController.h"
//tabbarVCs
#import "RoadVC.h"
#import "PromotionVC.h"

@interface StoppingTabBarVC ()

@end

@implementation StoppingTabBarVC

#pragma mark - life cycle

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self setTabBar];
    
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    btn.backgroundColor = [UIColor greenColor];
//    [self.view addSubview:btn];
    [btn addTarget:self action:@selector(btnAciton:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - event motheds

- (void)btnAciton:(UIButton *)sender {
    
    
    [self presentViewController:[[MovingTabBarVC alloc] init] animated:YES completion:nil];
}


#pragma mark - private methods

- (void)setTabBar {
    
    
    RoadVC *roadVC = [[RoadVC alloc] init];
    UINavigationController *roadNavi = [[UINavigationController alloc] initWithRootViewController:roadVC];
    
    UINavigationController *promotionNavi = [[UINavigationController alloc] initWithRootViewController:[[PromotionVC alloc] init]];
    
    
    ViewController *vc2 = [[ViewController alloc] init];
    vc2.view.backgroundColor  = [UIColor blueColor];
    
    ViewController *vc3 = [[ViewController alloc] init];
    ViewController *vc4 = [[ViewController alloc] init];
    self.viewControllers = @[roadNavi,promotionNavi,vc3,vc4];
    
    NSArray *titles = @[@"路途",@"优惠",@"商城",@"我"];
    for (UITabBarItem *item in self.tabBar.items) {
        
        NSInteger index = [self.tabBar.items indexOfObject:item];
        item.title  = titles[index];
        [item setTitleTextAttributes:@{NSForegroundColorAttributeName:WL_S_Bar_H_Color,NSFontAttributeName:[UIFont systemFontOfSize:15]} forState:UIControlStateSelected];
        [item setTitleTextAttributes:@{NSForegroundColorAttributeName:WL_S_Bar_N_Color,NSFontAttributeName:[UIFont systemFontOfSize:15]} forState:UIControlStateNormal];
        
        NSString *imageStr = [NSString stringWithFormat:@"icon_tabbar_%ld_normal",index];
        NSString *selectImageStr = [NSString stringWithFormat:@"icon_tabbar_%ld_select",index];
        item.image = [[UIImage imageNamed:imageStr] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        item.selectedImage = [[UIImage imageNamed:selectImageStr] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        
    }
    [self setNaviBarStyle];
    [self setTabBarStyle];
    
}

- (void)setTabBarStyle {
    
    [self.tabBar setBackgroundImage:[UIColor colorToImage:[UIColor whiteColor]]];
    [self.tabBar setShadowImage:[UIColor colorToImage:WL_line_Color]];
}

- (void)setNaviBarStyle {
    
    [[UINavigationBar appearance] setBackgroundImage:[UIColor colorToImage:WL_Top_Color] forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    [UINavigationBar appearance].tintColor = [UIColor whiteColor];

}


@end
